#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2023/11/18 19:20
# @Author  : FuKai ZHANG
# @File    : setting.py
# @Description :Linux 和window下路径统一
import os.path

from typing import Text


def rootpath():
    """获取当前项目的绝对路径"""
    path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    return path


def ensure_path_sep(path: Text) -> Text:
    """兼容windows和Linux不同环境的路径处理"""
    if "/" in path:
        path = os.sep.join(path.split("/"))  # Linux 路径

    if "\\" in path:
        path = os.sep.join(path.split("\\"))  # windows路径

    return rootpath() + path